<template>
  <div id="toast" v-show="isShow">
    <div class="container">
      {{ message }}
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      message: '',
      second: 1000,
      isShow: false,
    }
  },
  methods: {
    show(message = '请填入信息', second = 2000) {
      this.isShow = true
      this.message = message

      setTimeout(() => {
        this.isShow = false
        this.message = ''
      }, second)
    },
  },
}
</script>

<style lang="less" scoped>
#toast {
  .container {
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 9;
    padding: 5px 15px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #ffffff;
    font-size: 16px;
    text-align: center;
  }
}
</style>
